package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Version;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VersionDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "版本号")
    private String versionNumber;

    @ApiModelProperty(value = "下载地址")
    private String downloadLink;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "当前版本0否1是")
    private Integer isNowVersion;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "创建者")
    private String createAdmin;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "修改者")
    private String updateAdmin;

    @ApiModelProperty(value = "状态：1正常2删除")
    private Integer status;


    public VersionDTO() {}

    public VersionDTO(Version entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static VersionDTO convert(Version entity) {
        return new VersionDTO(entity);
    }

    public static List<VersionDTO> convertList(List<Version> list) {
        List<VersionDTO> resultList = new ArrayList<>();
        for (Version entity : list) {
            resultList.add(new VersionDTO(entity));
        }
        return resultList;
    }}
